<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="conversation.css" rel="STYLESHEET" type="text/css">
<title>Dialogue Act Label</title>
</head>
<body>

<!--        Header         -->
<jsp:include page="scripts/headerEdit.jsp">
  <jsp:param name="title" value="Dialogue Act Label" />
</jsp:include>

<div class="list">
	<spring:bind path="dalabel">
  	<c:forEach items="${status.errorMessages}" var="error">
			Error Message: <c:out value="${error}" />
    <br>
  </c:forEach>
</spring:bind>

<c:if test="${(! empty anno_user) && anno_user.role == 1}">
<form method="post">
<table>
  <tr>
    <th align="left">Scheme / Dimension</th>
    <th align="left">Label</th>
    <th align="left">Description</th>
  </tr>
  <tr valign="top">
    <td><spring:bind path="dalabel.dialogueActDimension">
      <select name='<c:out value="${status.expression}"/>'
        value='<c:out value="${status.value}"/>'>
        <c:forEach items="${da_dimensions}" var="dadimension">
          <option
            value='<c:out value="${dadimension.dialogueActDimensionId}"/>'
            <c:if test="${dalabel.dialogueActDimension.dialogueActDimensionId == dadimension.dialogueActDimensionId}">SELECTED
   				    </c:if>>
          <c:out value="${dadimension.dialogueActScheme.scheme}"/> / <c:out value="${dadimension.dimension}" /></option>
        </c:forEach>
      </select>
    </spring:bind></td>
    <td><spring:bind path="dalabel.label">
      <input name='<c:out value="${status.expression}"/>'
        value='<c:out value="${status.value}"/>' type="text" size="16"
        maxlength="32">
    </spring:bind></td>
    <td><spring:bind path="dalabel.description">
      <textarea cols="40" rows="5" name='<c:out value="${status.expression}"/>'>      
       <c:out value="${status.value}" />
       </textarea>

    </spring:bind></td>
  </tr>
</table>
<p align="center"><input name="save" value="Save" type="submit">
<input name="cancel" type="button" value="Cancel"
  onClick="javascript:window.location='enterdalabel.html'"></p>
</form>
</c:if>

<c:if test="${(empty anno_user) || anno_user.role != 1}">
<table>
  <tr>
    <th align="left">Scheme / Dimension</th>
    <th align="left">Label</th>
    <th align="left">Description</th>
  </tr>
  <tr valign="top">
  	<td>
  	  <c:out value="${dalabel.dialogueActDimension.dialogueActScheme.scheme}"/> / <c:out value="${dalabel.dialogueActDimension.dimension}" />
  	</td>
    <td>
      <c:out value="${dalabel.label}" />
    </td>    
    <td>
      <c:out value="${dalabel.description}" />
    </td>
  </tr>
</table>
</c:if>
</div>
<div class="list">

<h3>Messages annotated with this label</h3>
  <table>
  <tr>
    <th>ID</th>
    <th>Conv. </th>
    <th>No.</th>
    <th>S</th>
    <th width="300">Content</th>
    <th>Dialogue Acts</th>
  </tr>
  <c:forEach items="${dalabel.functionDialogueActs}" var="da">   
		<tr>
      <td><a href='annotatemessage.html?messageId=<c:out value="${da.message.messageId}"/>'><c:out value="${da.message.messageId}" /></a></td>
      <td><c:out value="${da.message.conversation.conversationId}" /></td>
    	<td><c:out value="${da.message.sequence}" /></td>
    	<td>
    		<c:if test="${da.message.speaker == 1}">
      		<font style="color: red">L</font>
      	</c:if> 
	  		<c:if test="${da.message.speaker == 2}">
  	  		<font style="color: blue">U</font>
      	</c:if>
    	</td>
    	<td><c:out escapeXml="false" value="${da.message.contentString}" /></td>
			<td>
    		<c:forEach items="${da.message.dialogueActs}" var="mda">        
      		<b>Function:</b> <c:out value="${mda.function.label}" />
        	<b>Domain:</b> <c:out value="${mda.domain.label}" />
        	<br/><br/>                      
      	</c:forEach> 
			</td>
  	</tr>  	
  </c:forEach>
	<c:forEach items="${dalabel.domainDialogueActs}" var="dda">   
		<tr>
      <td><a href='annotatemessage.html?messageId=<c:out value="${dda.message.messageId}"/>'><c:out value="${dda.message.messageId}" /></a></td>
      <td><a href='annotateconversation.html?conversationId=<c:out value="${dda.message.conversation.conversationId}"/>'><c:out value="${dda.message.conversation.conversationId}" /></a></td>
     	<td><c:out value="${dda.message.sequence}" /></td>
     	<td>
     		<c:if test="${dda.message.speaker == 1}">
       		<font style="color: red">L</font>
     		</c:if> 
	   		<c:if test="${dda.message.speaker == 2}">
      	  <font style="color: blue">U</font>
     		</c:if>
     	</td>
     	<td><c:out escapeXml="false" value="${dda.message.contentString}" /></td>
     	<td>
     		<c:forEach items="${dda.message.dialogueActs}" var="mda">        
         	<b>Function:</b> <c:out value="${mda.function.label}" />
         	<b>Domain:</b> <c:out value="${mda.domain.label}" />
         	<br/><br/>                      
       	</c:forEach> 
     	</td>
    </tr>
  	</c:forEach>
	</table>
</div>
<div class="list">
<h3>Current Dialogue Act Labels</h3>
<table>
  <tr>
    <th>Scheme</th>
    <th>Dimension</th>
    <th>Label</th>
    <th>Description</th>
  </tr>
  <c:forEach items="${dalabels}" var="dalabel">
    <tr>
      <td><c:out
        value="${dalabel.dialogueActDimension.dialogueActScheme.scheme}" /></td>
      <td><c:out value="${dalabel.dialogueActDimension.dimension}" /></td>
      <td><c:out value="${dalabel.label}" /></td>
      <td><c:out value="${dalabel.description}" /></td>
    </tr>
  </c:forEach>
</table>
</div>
</body>
</html>

